﻿using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IScreenCapture;

internal class ScreenCaptureService : IScreenCaptureService
{
   
    public Bitmap CaptureFullScreen(Rect rect)
    {

        //IReadOnlyList<Screen> screens =Screens.All;
        //var bounds = screens.Select(s => s.Bounds).Aggregate(Rect.Union);
        var rtb = new RenderTargetBitmap(
            new PixelSize((int)rect.Width, (int)rect.Height),
            new Vector(96, 96));
        rtb.Render(((IClassicDesktopStyleApplicationLifetime)Application.Current?.ApplicationLifetime!).MainWindow!);
        return rtb;
    }
}
